<?php

if (!defined('IN_XLP')) {
    exit('Access Denied!');
}

/**
 * Description of userReportModel
 * 用户举报
 * @author xlp
 */
class userReportModel extends model {

    function __construct() {
        parent::__construct();
        $this->dbTable = 'user_report';
    }

    /*
     * 添加举报消息
     * @param $uid int UID
     * @param $fuid int 被举报的UID
     * @param $rid int 被举报的内容ID
     * @param $fmod string 模块名称 
     * @param $content string 举报备注
     * @return int 记录编号
     */

    public function addReport($uid, $fuid, $rid, $fmod, $title = '', $content = '') {
        if (!C('mod', $fmod)) {
            showError('不存在的消息类型:' . $fmod);
        }
        if ($this->field('id')->where(array('fuid' => $fuid, 'rid' => $rid, 'fmod' => $fmod, 'uid' => $uid))->find()) {
            return false;
        }
        $objData = array();
        $list = $this->getTableFields();
        foreach ($list['fields'] as $key => $val) {
            $objData[$key] = $val['value'];
        }
        $objData['uid'] = $uid;
        $objData['fuid'] = $fuid;
        $objData['rid'] = $rid;
        $objData['fmod'] = $fmod;
        $objData['title'] = $title;
        $objData['content'] = $content;
        $objData['infotime'] = TIME;
        return $this->insert($objData);
    }

}
